package com.midou.administration.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.midou.administration.bo.IngredientsBo;
import com.midou.administration.bo.IngredientsBoB;
import com.midou.administration.bo.IngredientsBoFenye;
import com.midou.administration.entity.Ingredients;
import com.midou.administration.mapper.IngredientsMapper;
import com.midou.administration.service.IngredientsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author MrChen
 * @since 2021-03-24
 */
@Service
public class IngredientsServiceImpl implements IngredientsService {
    @Autowired
    private IngredientsMapper ingredientsMapper;
    public Page seekuncun(IngredientsBoFenye fenye){
        List<IngredientsBo> list=ingredientsMapper.ssekucun(fenye.getPage(),fenye.getBusinessId());
        fenye.getPage().setRecords(list);
        return fenye.getPage();
    }

    /**
     * 条件查询
     */
    public List<IngredientsBo> querymen(Integer leibie,String name,Integer id){
            return ingredientsMapper.querymany(leibie, name,id);
    }

    /**
     * 添加食材
     */
    public Integer tadd(IngredientsBoB ingredientsBoB){
        Ingredients ingredients=new Ingredients();
        ingredients.setIngredientstypeDate(new Date());
        ingredients.setIngredientsName(ingredientsBoB.getCname());
        ingredients.setIngredientsConut(ingredientsBoB.getCnum());
        ingredients.setIngredientsCompany(ingredientsBoB.getCdw());
        ingredients.setIngredientstypeId(ingredientsBoB.getIndexc());
        ingredients.setBusiness_id(ingredientsBoB.getBusinessId());
        return ingredientsMapper.insert(ingredients);
    }
    /**
     * 删除方法
     */
    public Integer dele(Integer id){
        return ingredientsMapper.deleteById(id);
    }
}
